package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author jiyonghui
 * @className ShipStatusEnum
 * @description
 * @date 2020/1/6   14:41
 */
@Getter
public enum ShipStatusEnum {
    // 出库状态
    UNSHIPPED("1", "enum.shipStatus.name.un_shipped", "unshipped"),
    DELIVERED("2", "enum.shipStatus.name.delivered", "delivered"),
    SHIPPED("3", "enum.shipStatus.name.shipped", "shipped"),
    CLOSED("4","enum.shipStatus.name.closed","closed")
    ;

    private String code;
    private String name;
    private String attr;

    ShipStatusEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static String getByCode(String code) {
        for (ShipStatusEnum value : ShipStatusEnum.values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getName();
            }
        }
        return null;
    }
}
